package com.boge.modules.house.service.impl;

import com.boge.modules.house.entity.THouseEntity;
import com.boge.modules.house.entity.THousepjEntity;
import com.boge.modules.house.service.THouseService;
import com.boge.modules.sys.entity.SysUserEntity;
import com.boge.modules.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.boge.common.utils.PageUtils;
import com.boge.common.utils.Query;

import com.boge.modules.house.dao.TFeedbackDao;
import com.boge.modules.house.entity.TFeedbackEntity;
import com.boge.modules.house.service.TFeedbackService;


@Service("tFeedbackService")
public class TFeedbackServiceImpl extends ServiceImpl<TFeedbackDao, TFeedbackEntity> implements TFeedbackService {

    @Autowired
    private THouseService houseService;

    @Autowired
    private SysUserService userService;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TFeedbackEntity> page = this.page(
                new Query<TFeedbackEntity>().getPage(params),
                new QueryWrapper<TFeedbackEntity>()
        );

        List<TFeedbackEntity> records = page.getRecords();
        if(records != null){
            for (TFeedbackEntity record : records) {
                Integer userId = record.getUserId();
                SysUserEntity userEntity = userService.getById(userId);
                record.setUserName(userEntity.getNickname());

            }
        }

        return new PageUtils(page);
    }

}